package be.dch.csv.processor;

import org.apache.log4j.Logger;

import be.dch.csv.validator.CellValidator;
import be.dch.exceptions.ValidationException;

public class StringProcessor extends AbstractCellProcessor {

    private static final Logger LOG = Logger.getLogger(StringProcessor.class);

    public StringProcessor() {
	super();
    }

    public StringProcessor(final CellValidator validator) {
	super(validator);
    }

    @Override
    public Object parse(final String input) {
	String result = null;
	if (this.getValidator() == null) {
	    result = input;
	} else {
	    try {
		this.getValidator().validate(input);
		result = input;
	    } catch (final ValidationException e) {
		StringProcessor.LOG.warn(e);
	    }
	}
	return result;

    }
}
